class PrizeDrawingController {

	def index = { redirect(action:chooseMeeting,params:params) }
	
	def chooseMeeting = {
		return [ meetingList: Meeting.list( params ) ]
	}
	
	def chooseWinners = {
		def meeting = Meeting.get( params.id )
		def attendees = new ArrayList(meeting.attendees)
		def winners = new ArrayList()
		
		def numberOfWinners = params.numberOfWinners.toInteger()
		log.fatal(numberOfWinners)
		
		numberOfWinners.times() {
			int winnerIndex = Math.random() * attendees.size()
			
			def winner = attendees[winnerIndex]
			winners.add(winner)			
			attendees.remove(winner)
		}
		
		
		
		return [winners : winners]		
	}
}

